chrony_package_installation:
  pkg.installed:
    - name: chrony

chrony_config:
  file.managed:
    - name: /etc/chrony.conf
    - source: salt://services/files/etc/chrony.conf
    - backup: minion
    - require:
      - pkg: chrony_package_installation

chrony_service:
  service.running:
    - name: chronyd
    - enable: True
    - reload: False
    - watch:
      - file: chrony_config

# 可选：验证时间同步状态
chrony_tracking_check:
  cmd.run:
    - name: chronyc tracking
    - require:
      - service: chrony_service
